home *** CD-ROM | disk | FTP | other *** search
/ Compatibles PC Magazine 22 / PC Mag HS 22 CD2.iso / sharewar / win / formsx / formdemo.sx_ / formdemo.sx
Encoding:
Text File  |  1996-07-03  |  3.5 KB  |  155 lines

  1. ////////////////////////////
  2. // General Initializers
  3. //
  4.  
  5. edit_box_init:
  6.     editbox "edit box" = "Type something into this edit box ..."
  7.     set focus "edit box"
  8.  
  9. rocket_help:
  10.     $form_dir = formula directory
  11.     help $form_dir,"\\formula.hlp"
  12.  
  13. rocket_help_topic: tc
  14.     $form_dir = formula directory
  15.     help $form_dir,"\\formula.hlp" link tc
  16.  
  17. start_game:
  18.     the_game = new script "game_1.sxt"
  19.     the_game call start_game
  20.     free the_game
  21.  
  22. start_calculator:
  23.     calculator = new script "calc.sxt"
  24.     calculator call init_calculator
  25.  
  26. //////////////////////////////////////////
  27. // Hypertext control
  28. //
  29. hypertext_init:
  30.     p1 = 0        // record history
  31.  
  32. hypertext_handler: element_name, topic, hlink, p
  33.     editbox "edit box" = "Page ",p," - ",$topic
  34.     p2 = p1
  35.     p1 = p
  36.  
  37. hypertext_page:
  38.     display hypertext "sample.fgh" page p
  39.  
  40. hypertext_search:
  41.     search hypertext "sample.fgh"
  42.  
  43. ///////////////////////////////////////////////
  44. // Graph initialization procedures
  45. //
  46. // initialize graph data and color arrays
  47.  
  48. init_graphs:
  49.  
  50. // generate an arrays of single and multiple series graph data
  51.  
  52.     my_single_data = new float[10]
  53.     for n = 0 to 9
  54.         my_single_data[n] = rnd 100 // random values 0 to 100
  55.  
  56.     my_multi_data = new float[3][10]
  57.     for n,m = 0,0 to 2,9
  58.         my_multi_data[n][m] = rnd 100    // random values 0 to 100
  59.  
  60.     my_stacked_data = new float[3][10]
  61.     for m = 0 to 9
  62.         total = 0
  63.         for n = 0 to 2
  64.             total = total + my_multi_data[n][m]
  65.         for n = 0 to 2
  66.             my_stacked_data[n][m] = my_multi_data[n][m] / total * 100
  67.  
  68. // generate pie graph data
  69.  
  70.     my_pie_data = new float[6]
  71.     total = 0
  72.     for n = 0 to 5
  73.         my_pie_data[n] = 10 + rnd 10 // random values 10 to 20
  74.         total = total + my_pie_data[n]
  75.     for n = 0 to 5
  76.         my_pie_data[n] = (my_pie_data[n] / total * 100) ~ 3
  77.             // ~ 3 - only three significant digits
  78.  
  79. // generate an array of colors
  80.  
  81.     my_colors = new byte[6][3]
  82.     my_colors[0][0] = 0,128,192 // blue
  83.     my_colors[1][0] = 192,96,128 // pink
  84.     my_colors[2][0] = 96,192,96 // green
  85.     my_colors[3][0] = 0,128,192 // blue
  86.     my_colors[4][0] = 192,96,128 // pink
  87.     my_colors[5][0] = 96,192,96 // green
  88.  
  89. //////////////////////////////////////////
  90. // Graph handlers
  91. //
  92. // return the graph data, colors, min value, max value, and increment
  93.  
  94. graph_handler_1: element_name
  95.  
  96.     return @my_single_data, @my_colors, 0, 100, 10
  97.  
  98. graph_handler_2: element_name
  99.  
  100.     return @my_multi_data, @my_colors, 0, 100, 10
  101.  
  102. graph_handler_3: element_name
  103.  
  104.     return @my_stacked_data, @my_colors, 0, 100, 10
  105.  
  106. graph_handler_4: element_name
  107.  
  108.     return @my_pie_data, @my_colors, 0, 100, 10
  109.  
  110. //////////////////////////////////////////
  111. // 3D Graph
  112. //
  113.  
  114. draw_3D_graph:
  115.     call space_cleanup
  116.     the_graph = new script "graph3d.sxt"
  117.     the_graph call display_graph
  118.     free the_graph
  119.  
  120. //////////////////////////////////////////
  121. // 3D Spaceship
  122. //
  123.  
  124. space_initialize:
  125.     break mode FALSE
  126.     the_spaceship = new script "starwar.sxt"
  127.     the_spaceship call initialize
  128.  
  129. space_mouse_move: x, y
  130.     the_spaceship call draw_angle: x, y
  131.  
  132. space_cleanup:
  133.     free the_spaceship
  134.  
  135. //////////////////////////////////////////
  136. // List box
  137. //
  138.  
  139. init_listbox:
  140.     $alphabet = "abcdefghijklmnopqrstuvwxyz"
  141.  
  142.     listbox "list box" tabs 0,60,120
  143.     for n = 1 to 40
  144.         my_length = 3 + rnd 10
  145.         my_offset = rnd (26 - my_length)
  146.         $item1 = $alphabet stroff my_offset strcnt my_length
  147.         my_length = 3 + rnd 10
  148.         my_offset = rnd (26 - my_length)
  149.         $item2 = $alphabet stroff my_offset strcnt my_length
  150.         listbox "list box" add n,". ",$item1," ",$item2
  151.  
  152.  
  153.  
  154.  
  155.